// pages/quxiao/quxiao.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    selceteds: 10000,
    yh_quxiao: [],
    order_mun: '',
    v: 10000,
    neirong: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var order_mun = options.order_id
    var that = this;
    that.setData({
      order_mun: order_mun
    })
    wx.request({
      url: 'https://wukongweixiu.cn/index/Order/getquxiao',
      data: {

      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      method: 'GET',
      success: function (res) {
        console.log(res)
        that.setData({
          yh_quxiao: res.data.genhuan_remake
        })

      },
      fail: function (res) { },
      complete: function (res) { }
    });
  },
  selceted: function (e) {
    var that = this;
    var selcet = e.currentTarget.dataset.id;
    console.log(e)
    var v = e.currentTarget.dataset.v;
    that.setData({
      selceteds: selcet,
      v: v
    })

  },
  neirong: function (e) {
    var that = this
    that.setData({
      neirong: e.detail.value
    })
  },
  tijiao: function () {
    var that = this
    var quxiao_remake = that.data.v + '>>>>' + that.data.neirong;
    if (that.data.v == 10000) {
      quxiao_remake = '其他>>>>' + that.data.neirong;
      if (that.data.neirong==''){
        wx.showToast({
          title: '请填写原因',
          duration: 3000,
        })
        return false;
      }
      
     
    }
    wx.request({
      url: 'https://wukongweixiu.cn/index/Order/genhuanshifu',
      data: {
        quxiao_remake: quxiao_remake,
        order_mun: that.data.order_mun
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      method: 'GET',
      success: function (res) {
        if (res.data.code==1){
          wx.showToast({
            title: '更换成功',
            duration: 3000,
            success: function () {
              wx.switchTab({
                url: '../ours/ours'
              });
            }
          })
        }else{
          wx.showToast({
            title: '更换失败',
            duration: 3000,
            success: function () {
              wx.switchTab({
                url: '../ours/ours'
              });
            }
          })
        }
        

      },
      fail: function (res) { },
      complete: function (res) { }
    });
  }


})